package com.pingbu.tijian.hospital.backapi.service;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pingbu.common.bean.ResultBean;
import com.pingbu.common.utils.PbSecretUtils;
import com.pingbu.tijian.hospital.backapi.bean.entity.Student;
import com.pingbu.tijian.hospital.backapi.bean.entity.UserInfo;
import com.pingbu.tijian.hospital.backapi.bean.entity.UserPermission;
import com.pingbu.tijian.hospital.backapi.mapper.StudentMapper;
import com.pingbu.tijian.hospital.backapi.mapper.UserInfoMapper;
import com.pingbu.tijian.hospital.backapi.mapper.UserPermissionMapper;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserPermissionService {

    private static Logger logger = LoggerFactory.getLogger(UserPermissionService.class);

    @Autowired
    private UserInfoMapper userInfoMapper;
    @Autowired
    private UserPermissionMapper userPermissionMapper;

    @Autowired
    private StudentMapper studentMapper;

    /**
     * 得到某个用户的所有权限
     * @param userId
     * @return
     */
    public ResultBean<List<String>> listUserPermissionsByUserId(String userId){
        UserPermission up = new UserPermission();
        up.setUser_id(userId);
        List<UserPermission> permissions = userPermissionMapper.list(up);
        List<String> lst = new ArrayList<>();
        for (UserPermission up2 : permissions) {
            lst.add(up2.getPermission_value());
        }
        return ResultBean.create(0,"success", lst);
    }

}
